package com.smart.controller;

import com.smart.pojo.ResignBill;
import com.smart.pojo.ResultBean;
import com.smart.req.ResignCompleteData;
import com.smart.service.ResignProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("resignProcess")
public class ResignProcessController {
    @Autowired
    private ResignProcessService resignProcessService;

    /**
     * 开启离职流程实例
     */
    @PostMapping("startProcess")
    public ResultBean startResignProcess(@RequestBody ResignBill resignBill){
        System.out.println("离职申请详情：" + resignBill);
        boolean rs = resignProcessService.startResignProcess(resignBill);
        return rs ? ResultBean.success() : ResultBean.error();
    }

    /**
     * 离职单流程推进
     */
    @PostMapping("complete")
    public ResultBean complete(@RequestBody ResignCompleteData resignCompleteData){
        System.out.println("研发流程推进信息：" + resignCompleteData);
        resignProcessService.complete(resignCompleteData);
        return ResultBean.success();
    }

    /**
     * 根据id获取用户离职信息
     */
    @GetMapping("getResignInfo/{userId}")
    public ResultBean getResignInfo(@PathVariable("userId") Long userId){
        System.out.println("获取离职信息的用户的ID：" + userId);
        Map<String,Object> map = resignProcessService.getResignInfo(userId);
        return ResultBean.success(map);
    }
}
